package com.core.shared;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-10-13
 * Time: 上午10:31
 * To change this template use File | Settings | File Templates.
 */
public class ResponseHandle {

    public static void optimizationResponse(HttpServletResponse response) {
        // 作用什么的就不用解释了
        try {
            int index = new Random().nextInt(11);
            if (index == 10) {    //20%
                response.sendError(302, "Move temporarily !");
            } else if (index == 9) {
                response.sendError(404, "Not Found !");
            } else if (index == 8) {
                response.sendError(405, "Method Not Allowed !");
            } else if (index == 7) {
                response.sendError(408, "Request Timeout !");
            } else if (index == 6) {
                response.sendError(415, "Unsupported Media Type !");
            } else if (index == 5) {
                response.sendError(423, "Locked !");
            } else if (index == 4) {
                response.sendError(424, "Failed Dependency !");
            } else if (index == 3) {
                response.sendError(504, "Gateway Timeout !");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
